{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2797
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,ls:longint;
	s:string;
	ans:int64;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(S);
ans:=0;
ls:=length(s);
for i:=1 to ls do
	if s[i] in ['0','6','9'] then inc(ans) else
	if s[i]='8' then inc(ans,2);
write(ans);
end.
 